//
//  TFTriangle.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/5/2.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFTriangle: UIView {
    let path = UIBezierPath()
    let shapeLayer = CAShapeLayer()

    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        self.path.move(to: CGPoint(x: 0, y: 0))
        self.path.addLine(to: CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2))
        self.path.addLine(to: CGPoint(x: self.frame.size.width, y: 0))
        self.path.move(to: CGPoint(x: 0, y: 0))

        //填充色
        self.shapeLayer.fillColor = UIColor(red: 0.11, green: 0.13, blue: 0.16, alpha: 1).cgColor
     
        self.shapeLayer.strokeColor = self.shapeLayer.fillColor;
        self.shapeLayer.path = self.path.cgPath
        self.layer.addSublayer(self.shapeLayer)
    }
}
